/**
 * Copyright &copy; 2015-2020 <a href="http://www.easyhis.com/">easyhis</a> All rights reserved.
 */
package com.easy.modules.iim.entity;

import com.easy.common.utils.IdGen;
import com.easy.common.utils.Reflections;
import com.easy.common.utils.StringUtils;
import com.easy.core.persistence.BaseEntity;
import com.easy.modules.sys.entity.User;
import com.easy.modules.sys.utils.UserUtils;
import org.hibernate.validator.constraints.Length;

import com.easy.common.utils.excel.annotation.ExcelField;
import com.easy.core.persistence.DataEntity;

import java.util.Date;

/**
 * 群组Entity
 * @author lgf
 * @version 2016-08-07
 */
public class LayGroupUser extends BaseEntity<LayGroupUser> {
	
	private static final long serialVersionUID = 1L;
	private Integer gpId;
	private String id;
	private Integer groupId;
	private User user;		// 用户
	private LayGroup group;		// 群组id 父类
	private String remarks;	// 备注
	private User createBy;	// 创建者
	private Date createTime;	// 创建日期
	private User updateBy;	// 更新者
	private Date updateTime;	// 更新日期
	private Integer delFlag; 	// 删除标记（0：正常；1：删除；2：审核）


	
	public LayGroupUser() {
		super();
	}

	public LayGroupUser(Integer groupId){
		this.groupId = groupId;
	}

	public LayGroupUser(LayGroup group){
		this.group = group;
	}

	public Integer getGpId() {
		return gpId;
	}

	public void setGpId(Integer gpId) {
		this.gpId = gpId;
	}

	public String getId() {
		return id;
	}

	public void setId(String id) {
		this.id = id;
	}

	public Integer getGroupId() {
		return groupId;
	}

	public void setGroupId(Integer groupId) {
		this.groupId = groupId;
	}

	@ExcelField(title="用户", fieldType=User.class, value="user.name", align=2, sort=7)
	public User getUser() {
		return user;
	}

	public void setUser(User user) {
		this.user = user;
	}
	
	@Length(min=0, max=64, message="群组id长度必须介于 0 和 64 之间")
	public LayGroup getGroup() {
		return group;
	}

	public void setGroup(LayGroup group) {
		this.group = group;
	}

	public String getRemarks() {
		return remarks;
	}

	public void setRemarks(String remarks) {
		this.remarks = remarks;
	}

	public User getCreateBy() {
		return createBy;
	}

	public void setCreateBy(User createBy) {
		this.createBy = createBy;
	}

	public Date getCreateTime() {
		return createTime;
	}

	public void setCreateTime(Date createTime) {
		this.createTime = createTime;
	}

	public User getUpdateBy() {
		return updateBy;
	}

	public void setUpdateBy(User updateBy) {
		this.updateBy = updateBy;
	}

	public Date getUpdateTime() {
		return updateTime;
	}

	public void setUpdateTime(Date updateTime) {
		this.updateTime = updateTime;
	}

	public Integer getDelFlag() {
		return delFlag;
	}

	public void setDelFlag(Integer delFlag) {
		this.delFlag = delFlag;
	}
	/**
	 * 插入之前执行方法，需要手动调用
	 */
	public void preInsert(){
		User user = UserUtils.getUser();
		if (user.getUserId()<1){
			this.updateBy = user;
			this.createBy = user;
		}
		this.updateTime = new Date();
		this.createTime = this.updateTime;
	}
	/**
	 * 更新之前执行方法，需要手动调用
	 */
	public void preUpdate(){
		User user = UserUtils.getUser();
		if (user.getUserId()<1){
			this.updateBy = user;
		}
		this.updateTime = new Date();
	}

}